<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { useRoute } from "vue-router";
import { router } from "@/router";
import { tabsList } from "./helps";

import MainNodeScheduledTask from "./components/mainNodeScheduledTask.vue";
import ChildNodeScheduledTask from "./components/childNodeScheduledTask.vue";

const route = useRoute();
const activeTab = ref("0");

// 获取URL参数中的task
const taskParam = ref((route.query.task as string) || "");
</script>

<template>
  <div>
    <el-tabs type="border-card">
      <el-tab-pane
        v-for="item in tabsList"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <!-- 主节点计划任务 -->
        <MainNodeScheduledTask
          :task="taskParam"
          v-if="item.key === 'main_node_task'"
        />

        <!-- 子节点计划任务 -->
        <ChildNodeScheduledTask
          :task="taskParam"
          v-if="item.key === 'child_node_task'"
        />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<style lang="scss" scoped>
:deep(.el-card__header) {
}

.search-form-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.el-btn-zese {
  background: #722ed1;
  color: white;
  border-color: #722ed1;
}

.el-btn-zese.is-disabled,
.el-btn-zese.is-disabled:focus,
.el-btn-zese.is-disabled:hover {
  background: #722ed1;
  color: white;
  border-color: #722ed1;
}
.task-name {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
  padding: 10px;
  border-radius: 5px;
}
</style>
